package com.haoxi.gateway.common;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.TimerTask;
import java.sql.CallableStatement;

public class InsSumtTable extends TimerTask {
    private String url = "jdbc:oracle:thin:@218.204.253.205:1521:smsnew";
    private String user = "smsp";
    private String password = "haoxismsp";
    private String sql = "{call bacth_insert_sumit(?,?,?,?,?)}";

    public InsSumtTable() {


        // Connection conn= DriverManager.getConnection(url,user,password);
        // Statement
        // stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
        // String sql="select * from MEMBER order by id desc";
        // ResultSet rs=stmt.executeQuery(sql);
        // while(rs.next())
    }
    
    public void insToSumit()
    {
        Connection conn=null;
        CallableStatement stat=null;
        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
            conn = getConnection();
            conn.setAutoCommit(false);
            stat = conn.prepareCall(sql);
            stat.setInt(1, 100);
            stat.setInt(2, 164);
            stat.setString(3, "13800138000");
            stat.setString(4, "13800138000");
            stat.setString(5, "测试测试消息");
            stat.execute();
            conn.commit();
            stat.close();
            conn.close();
        } catch (Exception ex) {
          
            try
            {
            stat.close();
            conn.close();
            }
            catch(Exception ex1)
            {
                ex1.printStackTrace();
            }
            ex.printStackTrace();
        }
    }

    public Connection getConnection() throws SQLException {
        Connection conn = DriverManager.getConnection(url, user, password);
        return conn;

    }

    public void run() {

    }
    public static void main(String[] args) {
        
       new InsSumtTable().insToSumit();
    }

}
